<script setup lang="ts">
import { ref } from 'vue';

const props = defineProps<{
    defaultToRight?:boolean
}>()
const rightSide = ref(props.defaultToRight||false)
function clickHandler(){
    const to = !rightSide.value;
    rightSide.value = to;
    emit('changed', to)
}
const emit = defineEmits<{
    (e:'changed', isRightSide:boolean):void
}>()
</script>

<template>
<div class="lrSwitch" @click="clickHandler">
    <div class="switchHandle" :class="{right:rightSide}">

    </div>
</div>
</template>

<style scoped>
.lrSwitch{
    height: 20px;
    width: 40px;
    position: relative;
    border-radius: 100px;
    border: 2px solid gray;
    background-color: white;
    margin: 0px 3px 0px 3px;
}
.switchHandle{
    position: absolute;
    top: 2px;
    bottom: 2px;
    left: 2px;
    right: unset;
    width: 20px;
    border-radius: 100px;
    background-color: gray;
}
.right{
    left: unset;
    right: 2px;
}
</style>